﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using BLL;
namespace 健身房管理
{
    public partial class UserMember : UserControl
    {
        huiyuanBLL hbl = new huiyuanBLL();
        public UserMember()
        {
            InitializeComponent();
        }

        //public DataTable cx()
        //{
        //    SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=Print;Integrated Security=True");
        //    string sql = string.Format("select * from test ");
        //    SqlDataAdapter sdr = new SqlDataAdapter(sql, con);
        //    DataTable dt = new DataTable();
        //    sdr.Fill(dt);
        //    return dt;
        //}

        private void UserMember_Load(object sender, EventArgs e)
        {
            jiaz();
        }
        public void jiaz()
        {
            DataTable dt = hbl.hydgvshow();
            this.dgvView.DataSource = dt;
            
        }
        private void guna2Button2_Click(object sender, EventArgs e) //查询
        {

            string name = this.cxnametxt.Text;
            int jymember = 0 ;
            
            if (guna2CheckBox2.Checked)
            {
                jymember = 1;
            }
            int leave = 0;
            if (guna2CheckBox1.Checked)
            {
                leave = 2;
            }
            DataTable dt = hbl.mReach1(name, jymember, leave);
            this.dgvView.DataSource = dt;
        }

        private void guna2Button6_Click(object sender, EventArgs e)
        {
            PrintDGV.Print_DataGridView(this.dgvView);
        }

        private void guna2Button1_Click(object sender, EventArgs e)
        {
            mAdd madd = new mAdd();
            madd.Show();
            //Form1 fm1 = new Form1();
            //fm1.Show();
        }

        private void 刷新ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            jiaz();
        }

        private void guna2Button5_Click(object sender, EventArgs e)
        {
            int a = int.Parse(this.dgvView.CurrentRow.Cells["id"].Value.ToString());
            mModify xg = new mModify();
            xg.id = a;
            xg.ShowDialog();
        }

        private void guna2Button7_Click(object sender, EventArgs e)
        {
            int id = int.Parse(this.dgvView.CurrentRow.Cells["id"].Value.ToString());
            mModify xg = new mModify();
            
            bool b1 = hbl.mModifyDel(id);
            if (b1)
            {
                MessageBox.Show("删除成功");
            }
            else
            {
                MessageBox.Show("删除失败");
            }
        }

        private void guna2CheckBox2_CheckedChanged(object sender, EventArgs e)
        {
        }

        private void guna2CheckBox1_CheckedChanged(object sender, EventArgs e)
        {
        }

        private void guna2Button9_Click(object sender, EventArgs e)
        {
            jiaz();
        }
    }
}
